home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOX10DOS.ZIP / TIPS < prev   
Text File  |  1993-10-04  |  5KB  |  147 lines

  1.  
  2. SOX usage:
  3.     sox [options] from-file-args to-file-args [ effect [effect-args]]
  4.  
  5. First off: the -V option makes SOX print out its idea of
  6. what it is doing.  -V is your friend.
  7.     
  8.     sox -V from-file-args to-file-args
  9.  
  10. From-file-args and to-file-args are the same. 
  11. They are a series of options followed by a file name.
  12. The suffix on the file name usually is the file format type.
  13. The '-t xx' option overrides this and tells sox 
  14. the the file format is 'xx'.  The '-u/-s/-U' arguments
  15. say that the file is in unsigned, signed, or u-law format.
  16. The '-b/-w' arguments say that the file is in byte- or
  17. word-size (2 byte) samples.  The '-r number' argument
  18. says that the sample rate of the file is 'number'.
  19.  
  20. The extensions ub, uw, sb, sw, and ul correspond
  21. to raw data files of formats unsigned byte, unsigned 
  22. word, signed byte, signed word, and u-law byte.
  23. Thus, '-t ul' is shorthand for '-t raw -U -b'.
  24.  
  25. These conversions clip data and thus reduce sound quality, 
  26. so be careful:
  27.  
  28.     Word to u-law.
  29.     Word to byte.
  30.     U-law to byte.
  31.     Reduction in sample rate.
  32.  
  33. Any reduction in the sample data rate loses information
  34. and adds noise.  An increase in the data rate doesn't
  35. lose much information, but does add noise.  See the
  36. note below on low-pass filtering.
  37.  
  38. To convert U-law to something else without clipping,
  39. you'll have to convert it to (signed or unsigned) words,
  40. which will double the size of the file.
  41.  
  42. AUTO files:
  43. The 'AUTO' file type reads an unknown file and
  44. attempts to discern its binary format.
  45.  
  46. AIFF files:
  47. AIFF files come with complete headers and other
  48. info.  They can in fact have multiple sound
  49. chunks and picture chunks.  SOX only reads
  50. the first sound chunk. 
  51.  
  52. WAV files:
  53. WAVs use the RIFF format, which is Microsoft's
  54. needless imitation of AIFF.  See above comments.
  55.  
  56. AIFF and RIFF files need their own librarian
  57. programs; SOX can only do a small fraction of
  58. what they need.
  59.  
  60. It's best if you can copy or store files in
  61. AIFF or WAV format.  The sample rate and 
  62. binary format are marked; also comments may 
  63. be added to the file.
  64.  
  65. SUN AU files:
  66. Most AU files you find are in 8khz 8-bit u-law format.
  67. This format was the first sound hardware SUN made available.
  68. Some of the files have correct headers; some do not.
  69. If the file has the header, this should convert it to
  70. another format:
  71.  
  72.     sox file.au to-file-args
  73.  
  74. If not, this reads a raw u-law 8khz file:
  75.     
  76.     sox -t ul -r 8012 file.au to-file-args
  77.  
  78. To convert a file to an old-style SUN .au file:
  79.  
  80.     sox from-file-args -r 8012 -U -b file.au
  81.  
  82. AU format can have any speed and several data sizes;
  83. you need to specify '-r 8012 -U -b' to force SOX to
  84. use the old SUN format.
  85.  
  86. Mac files:
  87. Mac files come in .snd, .aiff, and .hcom formats,
  88. among others; these are the most common.
  89.  
  90. SND files are in unsigned byte format with no
  91. header.  They are either 11025, 22050, or 44100 hz.
  92. The speed seems to be a "resource" and doesn't
  93. get transported to Unix when the files are.
  94. Thus, you just have to know.
  95.  
  96.     sox -r 11025 -t ub file.snd to-file-args
  97.     sox from-file-args -r 11025 -t ub file.snd
  98.  
  99. PC files:
  100. There are several PC sound file formats. VOC is
  101. common; it has headers.  SND and SNDR are for
  102. some DOS sound package; I don't know much about them.
  103. WAV is the official Microsoft Windows format.
  104. WAV has format options for compressed sound;
  105. SOX doesn't implement this yet.  
  106.  
  107.  
  108. Effects:
  109. A sound effect may be applied to the sound sample
  110. while it is being copied from one file to another.
  111. Copy is the default effect; i.e. do nothing.
  112. Changing the sample rate requires the 'rate'
  113. effect.  This applies a simple linear interpolation
  114. to the sample.  This is a poor-quality sample
  115. changer.  After doing a rate conversion,
  116. you should try doing a low-pass filter to throw
  117. away some of the induced noise.  Pick a 'center'
  118. frequency about 85% of the lower of the two
  119. frequencies, or 42.5% of the lower of the
  120. two sample rates.  (The maximum frequency
  121. in a sample is 1/2 of the sample rate).
  122.  
  123.     sox -r 8000 file.xx -r 22050 tmp.yy
  124.     sox tmp.yy file.yy lowp 3400
  125. or:
  126.     sox -r 44100 file.xx -r 22050 tmp.yy
  127.     sox tmp.yy file.yy lowp 9592
  128.  
  129. Listen to both tmp.yy and file.yy and see if 
  130. the low-pass filter helps.  Be sure to do the
  131. low-pass filter before clipping the data to
  132. a smaller binary word size.  Say you have a 16-bit
  133. CD-quality (44100 hz) AIFF file that you want 
  134. to convert to a Mac sound resource:
  135.  
  136.     sox -r 44100 file.aiff -r 11025 tmp.sw
  137.     sox tmp.sw -t ub file.mac lowp 9371
  138.  
  139. not:
  140.  
  141.     sox -r 44100 file.aiff -r 11025 tmp.ub
  142.     sox tmp.ub -t ub file.mac lowp 9371
  143.  
  144. because you want to do the low-pass filter while 
  145. you still have sixteen-bit data.
  146.  
  147.